package idv.arthur.WebService;

//import it.sauronsoftware.ftp4j.FTPClient;
import java.io.BufferedInputStream;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import javax.xml.rpc.ServiceException;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;


public class CommonUtil {

    private static Call initial() throws ServiceException, MalformedURLException {

        //String endpoint = "http://10.144.31.137:7001/WWW0WS/services/CommonUtilWS";
        //String endpoint = "http://10.80.71.71:8061/services/CommonUtilWS";
        //String endpoint = "http://10.144.31.137:7001/WWWS/services/CommonUtilWS";
        String endpoint = "http://10.80.71.72:8006/WWWS/services/CommonUtilWS";

        Service service = new Service();

        Call call = (Call) service.createCall();

        call.setTargetEndpointAddress(new java.net.URL(endpoint));

        return call;
    }

    public static String qryEmpAgentInfo(String UserID) {
        try {
            //setLog4J("debug", "com.cht.sys.CommonUtil", "qryEmpAgentInfo :" + UserID);
            Object[] params;
            Call call = initial();

            call.setOperationName("qryEmpAgentInfo");
            params = new Object[] {UserID};

            String ret = (String) call.invoke(params);
            //ret = new String(ret.getBytes("ISO-8859-1"), "Big5");

            return ret;
        }
        catch (Exception e) {
            return "NULL";
        }
    }

    public static String getOfficecode(String UserID) {
        try {
            setLog4J("debug", "com.cht.sys.CommonUtil", "getOfficecode :" + UserID);
            Object[] params;
            Call call = initial();

            call.setOperationName("getOfficecode1");
            params = new Object[] {UserID};

            String ret = (String) call.invoke(params);
            ret = new String(ret.getBytes("ISO-8859-1"), "Big5");

            return ret;
        }
        catch (Exception e) {
            return "NULL";
        }
    }

    public static String getOfficecode(String UserID, String SSO_sessionid) {
        try {
            setLog4J("debug", "com.cht.sys.CommonUtil", "getOfficecode :" + UserID + "," + SSO_sessionid);
            Object[] params;
            Call call = initial();

            call.setOperationName("getOfficecode2");
            params = new Object[] {UserID, SSO_sessionid};

            String ret = (String) call.invoke(params);
            ret = new String(ret.getBytes("ISO-8859-1"), "Big5");

            return ret;
        }
        catch (Exception e) {
            return "NULL";
        }
    }

    public static String getOfficecode(String UserID, char supp_flag) {
        try {
            setLog4J("debug", "com.cht.sys.CommonUtil", "getOfficecode :" + UserID + "," + supp_flag);
            Object[] params;
            Call call = initial();

            call.setOperationName("getOfficecode3");
            params = new Object[] {UserID, String.valueOf(supp_flag)};

            String ret = (String) call.invoke(params);
            ret = new String(ret.getBytes("ISO-8859-1"), "Big5");

            return ret;
        }
        catch (Exception e) {
            return "NULL";
        }
    }

    public static String getEmail(String employeeno) {
        try {
            setLog4J("debug", "com.cht.sys.CommonUtil", "getEmail :" + employeeno);
            Object[] params;
            Call call = initial();

            call.setOperationName("getEmail");
            params = new Object[] {employeeno};

            String ret = (String) call.invoke(params);
            ret = new String(ret.getBytes("ISO-8859-1"), "Big5");

            return ret;
        }
        catch (Exception e) {
            return "";
        }
    }

    public static String getEmployee(String grantee, String colname) {
        try {
            setLog4J("debug", "com.cht.sys.CommonUtil", "getEmployee :" + grantee + "," + colname);
            Object[] params;
            Call call = initial();

            call.setOperationName("getEmployee");
            params = new Object[] {grantee, colname};

            String ret = (String) call.invoke(params);
            ret = new String(ret.getBytes("ISO-8859-1"), "Big5");

            return ret;
        }
        catch (Exception e) {
            return "";
        }
    }

    public static String getDepartment(String UserID) {
        try {
            setLog4J("debug", "com.cht.sys.CommonUtil", "getDepartment :" + UserID);
            Object[] params;
            Call call = initial();

            call.setOperationName("getDepartment");
            params = new Object[] {UserID};

            String ret = (String) call.invoke(params);
            ret = new String(ret.getBytes("ISO-8859-1"), "Big5");

            return ret;
        }
        catch (Exception e) {
            return "ER";
        }
    }

    public static String getOffice(String officecode) {
        try {
            setLog4J("debug", "com.cht.sys.CommonUtil", "getOffice :" + officecode);
            Object[] params;
            Call call = initial();

            call.setOperationName("getOffice");
            params = new Object[] {officecode};

            String ret = (String) call.invoke(params);
            ret = new String(ret.getBytes("ISO-8859-1"), "Big5");

            return ret;
        }
        catch (Exception e) {
            return "查無此營業單位";
        }
    }

    public static String getUserName(String UserID) {
        try {
            setLog4J("debug", "com.cht.sys.CommonUtil", "getUserName :" + UserID);
            Object[] params;
            Call call = initial();

            call.setOperationName("getUserName");
            params = new Object[] {UserID};

            String ret = (String) call.invoke(params);
            ret = new String(ret.getBytes("ISO-8859-1"), "Big5");

            return ret;
        }
        catch (Exception e) {
            return "查無此人";
        }
    }

    public static boolean isUserInRole(String employeeno, String _group, String _class) {
        try {
            setLog4J("debug", "com.cht.sys.CommonUtil", "isUserInRole :" + employeeno + "," + _group + "," + _class);
            Object[] params;
            Call call = initial();

            call.setOperationName("isUserInRole");
            params = new Object[] {employeeno, _group, _class};

            Object retobj = call.invoke(params);

            if(retobj.equals("true")) {
                return true;
            }
            else {
                return false;
            }

        }
        catch (Exception e) {
            return false;
        }
    }

    public static int getDutyCount(String employeeno) {
        try {
            setLog4J("debug", "com.cht.sys.CommonUtil", "getDutyCount :" + employeeno);
            Object[] params;
            Call call = initial();

            call.setOperationName("getDutyCount");
            params = new Object[] {employeeno};

            String retstr = (String) call.invoke(params);
            int retint = Integer.parseInt(retstr);

            return retint;
        }
        catch (Exception e) {
            return 0;
        }
    }

    public static boolean isUserInDuty(String employeeno, String s) {
        try {
            setLog4J("debug", "com.cht.sys.CommonUtil", "isUserInDuty :" + employeeno + "," + s);
            Object[] params;
            Call call = initial();

            call.setOperationName("isUserInDuty");
            params = new Object[] {employeeno, s};

            Object retobj = call.invoke(params);

            if(retobj.equals("true")) {
                return true;
            }
            else {
                return false;
            }

        }
        catch (Exception e) {
            return false;
        }
    }

    public static String getDutyName(String dutycode) {
        try {
            setLog4J("debug", "com.cht.sys.CommonUtil", "getDutyName :" + dutycode);
            Object[] params;
            Call call = initial();

            call.setOperationName("getDutyName");
            params = new Object[] {dutycode};

            String ret = (String) call.invoke(params);
            ret = new String(ret.getBytes("ISO-8859-1"), "Big5");

            return ret;
        }
        catch (Exception e) {
            return "";
        }
    }

    public static String getAlert() {
        try {
            setLog4J("debug", "com.cht.sys.CommonUtil", "getAlert :");
            Object[] params;
            Call call = initial();

            call.setOperationName("getAlert");
            params = new Object[] {};

            String ret = (String) call.invoke(params);
            ret = new String(ret.getBytes("ISO-8859-1"), "Big5");

            return ret;
        }
        catch (Exception e) {
            return "";
        }
    }

    public static int setSendMail(Map MailMap) {
        try {
            setLog4J("debug", "com.cht.sys.CommonUtil", "setSendMail :(Map)MailMap");

            String str = "";

            //String[] from = (String[]) MailMap.get("from");
            ArrayList to = (ArrayList) MailMap.get("to");
            String subject = (String) MailMap.get("subject");
            String text = (String) MailMap.get("text");

            str = subject + "," + text;

            for (int i = 0 ; i < to.size() ; i++) {
                String[] toList = (String[]) to.get(i);
                String toName = toList[0];
                String toEmail = toList[1];

                str = str + "," + toName + "-" + toEmail;
            }

            Object[] params;
            Call call = initial();

            call.setOperationName("setSendMail");
            params = new Object[] {str};

            String retstr = (String) call.invoke(params);
            int retint = Integer.parseInt(retstr);

            return retint;
        }
        catch (Exception e) {
            return 0;
        }
    }

    public static boolean setUserAuth(String action, String userid, String username, String organization, Set dutylist) {
        try {
            setLog4J("debug", "com.cht.sys.CommonUtil", "setUserAuth :" + action + "," + userid + "," + username + "," + organization + "," + "(Set)dutylist");

            String str = "";
            Iterator it = dutylist.iterator();

            while (it.hasNext()) {
                str = str + it.next() + ",";
            }

            Object[] params;
            Call call = initial();

            call.setOperationName("setUserAuth");
            params = new Object[] {action, userid, username, organization, str};

            Object retobj = call.invoke(params);

            if(retobj.equals("true")) {
                return true;
            }
            else {
                return false;
            }

        }
        catch (Exception e) {
            return false;
        }
   }

   public static String getUserID(String SSO_sessionid) {
        try {
            setLog4J("debug", "com.cht.sys.CommonUtil", "getUserID :" + SSO_sessionid);
            Object[] params;
            Call call = initial();

            call.setOperationName("getUserID");
            params = new Object[] {SSO_sessionid};

            String ret = (String) call.invoke(params);
            ret = new String(ret.getBytes("ISO-8859-1"), "Big5");

            return ret;
        }
        catch (Exception e) {
            return "";
        }
   }

   public static ArrayList getDutyList(String employeeno) {
        try {
            setLog4J("debug", "com.cht.sys.CommonUtil", "getDutyList :" + employeeno);
            Object[] params;
            Call call = initial();

            call.setOperationName("getDutyList1");
            params = new Object[] {employeeno};

            String ret = (String) call.invoke(params);
            ret = new String(ret.getBytes("ISO-8859-1"), "Big5");

            String[] tokens = ret.split(",");

            ArrayList list = new ArrayList();

            for(int i = 0 ; i < tokens.length ; i++) {
                list.add(tokens[i]);
            }

            return list;
        }
        catch (Exception e) {
            return new ArrayList();
        }
   }

   public static ArrayList getDutyList(String employeeno, String officecode) {
        try {
            setLog4J("debug", "com.cht.sys.CommonUtil", "getDutyList :" + employeeno + "," + officecode);
            Object[] params;
            Call call = initial();

            call.setOperationName("getDutyList2");
            params = new Object[] {employeeno, officecode};

            String ret = (String) call.invoke(params);
            ret = new String(ret.getBytes("ISO-8859-1"), "Big5");

            String[] tokens = ret.split(",");

            ArrayList list = new ArrayList();

            for(int i = 0 ; i < tokens.length ; i++) {
                list.add(tokens[i]);
            }

            return list;
        }
        catch (Exception e) {
            return new ArrayList();
        }
   }

   public static Set getUserByDuty(String duty) {
        try {
            setLog4J("debug", "com.cht.sys.CommonUtil", "getUserByDuty :" + duty);
            Object[] params;
            Call call = initial();

            call.setOperationName("getUserByDuty");
            params = new Object[] {duty};

            String ret = (String) call.invoke(params);
            ret = new String(ret.getBytes("ISO-8859-1"), "Big5");

            String[] tokens = ret.split(",");

            Set UserSet = new HashSet();

            for(int i = 0 ; i < tokens.length ; i++) {
                UserSet.add(tokens[i]);
            }

            return UserSet;
        }
        catch (Exception e) {
            return new HashSet();
        }
   }

   public static Set getUserNameSet(Set UserSet) {
        try {
            setLog4J("debug", "com.cht.sys.CommonUtil", "getUserNameSet :(Set)UserSet");

            String str = "";
            Iterator it = UserSet.iterator();

            while (it.hasNext()) {
                str = str + it.next() + ",";
            }

            Object[] params;
            Call call = initial();

            call.setOperationName("getUserNameSet");
            params = new Object[] {str};

            String ret = (String) call.invoke(params);
            ret = new String(ret.getBytes("ISO-8859-1"), "Big5");

            String[] tokens = ret.split(",");

            ArrayList list = new ArrayList();

            for(int i = 0 ; i < tokens.length ; i++) {
                list.add(tokens[i]);
            }

            Set UserNameSet = new HashSet();

            for (int i = 0 ;  i < list.size() ; i++) {
                String[] tokens2 = ((String) list.get(i)).split("-");

                String employeeno = tokens2[0];
                String employeename = tokens2[1];
                String office = tokens2[2];

                String[] UserNameTemp = { employeeno, employeename, office };
                UserNameSet.add(UserNameTemp);
            }

            return UserNameSet;
        }
        catch (Exception e) {
            return new HashSet();
        }
   }


//============================   以上使用 Web Service 處理   ========================================

//============================  以下不使用 Web Service 處理  ========================================


    /*public static void setLog(String level, String mySubsystem, String message) {

        try {
            weblogic.logging.NonCatalogLogger log = new weblogic.logging.NonCatalogLogger(mySubsystem);

            if (level == "info") {
                log.info(message);
            } else if (level == "debug") {
                log.debug(message);
            } else if (level == "error") {
                log.error(message);
            } else if (level == "warning") {
                log.warning(message);
            } else if (level == "emergency") {
                log.emergency(message);
            } else if (level == "critical") {
                log.critical(message);
            } else if (level == "alert") {
                log.alert(message);
            } else {
                log.error("Log Level Error :" + level);
            }
        } catch (Exception e) {
            System.err.println("Set NonCatalog Error：" + e);
        }
    }*/

    public static void setLog4J(String level, String Log4JClass, String message) {

        try {
            String serverGroup = System.getProperty("server.group");
            if (serverGroup != null
                    && (serverGroup.equals("OnLine") || serverGroup.equals("Verify") || serverGroup.equals("Backup") || serverGroup.equals("QA") || serverGroup
                            .equals("SD"))) {
                DOMConfigurator.configure("/home/weblogic/System.Property/WWW0/Log4j/log4j.xml");// 載入.xml文件
            } else {
                DOMConfigurator.configure("C:\\SOD Project\\log4j.xml");// 載入.xml文件
            }

            Logger logger = Logger.getLogger(Log4JClass);

            if (level == "debug") {
                logger.debug(message);
            } else if (level == "info") {
                logger.info(message);
            } else if (level == "warn") {
                logger.warn(message);
            } else if (level == "error") {
                logger.error(message);
            } else if (level == "fatal") {
                logger.fatal(message);
            } else {
                logger.error("Log Level Error :" + level);
            }
        } catch (Exception e) {
            System.err.println("Set Log4J Error：" + e);
        }
    }

    public static boolean getBLOB(String dir, String filename, String colname, ResultSet rs) {

        boolean retValue = false;
        File dir_1 = new File(dir);

        try {
            dir_1.mkdirs();
            String filename_6 = new String(filename.getBytes("ISO-8859-1"), "MS950");
            File f6 = new File(dir, filename_6);
            f6.createNewFile();

            while (rs.next()) {
                // row++;
                InputStream file = rs.getBinaryStream(colname);
                BufferedInputStream bi = new BufferedInputStream(file);
                OutputStream out = new FileOutputStream(f6);
                BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(out, "ISO-8859-1"));

                int f = 0;
                while ((f = bi.read()) != -1) {
                    bw.write(f);
                }
                bw.flush();
            }
            retValue = true;
        } catch (Exception e) {
            System.err.println(e);
        }
        return retValue;
    }

    static public int setBLOB(String dir, String filename, int colindex, PreparedStatement ps) {

        int retValue = 0;

        try {
            File f6 = new File(dir, filename);
            // String filename_6 = new
            // String(filename.getBytes("ISO-8859-1"),"MS950");
            int if6 = new Long(f6.length()).intValue();
            InputStream is = new FileInputStream(f6);
            ps.setBinaryStream(colindex, is, if6);
            retValue = ps.executeUpdate();
        } catch (Exception e) {
            System.err.println(e);
        }
        return retValue;
    }

    /**
     *@param request
     *            http 網路呼叫
     *@return 使用者 ID
     */
    /*static public String getUserID(javax.servlet.http.HttpServletRequest request) {
        // HttpSession session = request.getSession();
        String UserID = request.getRemoteUser();
        // session.setAttribute("UserID",UserID);
        return UserID;
    }*/

    /**
     *@param request
     *            http 網路呼叫
     *@return 使用者來源 IP
     */
  /*  static public String getRemoteIP(javax.servlet.http.HttpServletRequest request) {
        String RemoteIP = request.getHeader("WL-Proxy-Client-IP");
        if (RemoteIP == null || RemoteIP.equals("null") || RemoteIP == " ") {
            RemoteIP = request.getHeader("X-Forwarded-For");
            // RemoteIP = request.getHeader("Proxy-Client-IP");
            if (RemoteIP == null || RemoteIP.equals("null") || RemoteIP == " ") {
                RemoteIP = request.getRemoteAddr();
            }
        }
        return RemoteIP;
    }*/

    /**
     *@param local_dir
     *            檔案所在本地端路徑
     *@param filename
     *            檔案名稱
     *@param host
     *            遠端主機名稱或 IP Address
     *@param port
     *            遠端主機 FTP 服務連接埠
     *@param remote_dir
     *            檔案所在遠端路徑
     *@param login_account
     *            遠端登入帳號
     *@param login_passwd
     *            遠端登入密碼
     *@return 是否成功
     */
    /*static public boolean uploadFtpFile(String local_dir, String filename, String host, int port, String remote_dir, String login_account, String login_passwd)
            throws Exception {

        boolean returnValue = false;
        File outputfile = new File(local_dir, filename);
        boolean disconnectflag = true;
        FTPClient client = new FTPClient();

        try {
            client.connect(host, port);
            try {
                client.login(login_account, login_passwd);
                try {
                    client.setType(2);
                    client.changeDirectory(remote_dir);
                    client.upload(outputfile);
                    client.disconnect(disconnectflag);
                    returnValue = true;
                    setLog4J("debug", "com.cht.sys.CommonUtil", "CommonUtil.java uploadFtpFileFTP Success");
                } catch (Exception e13) {
                    setLog4J("error", "com.cht.sys.CommonUtil", "CommonUtil.java uploadFtpFileFTP : " + e13);
                }

            } catch (Exception e12) {
                setLog4J("error", "com.cht.sys.CommonUtil", "CommonUtil.java uploadFtpFileFTP Login [" + login_account + "] Fail : " + e12);
            }
        } catch (Exception e11) {
            setLog4J("error", "com.cht.sys.CommonUtil", "CommonUtil.java uploadFtpFileFTP Connect [" + host + ":" + port + "] Fail : " + e11);
        }
        return returnValue;
    }

    *//**
     *@param local_dir
     *            檔案所在本地端路徑
     *@param filename
     *            檔案名稱
     *@param host
     *            遠端主機名稱或 IP Address
     *@param port
     *            遠端主機 FTP 服務連接埠
     *@param login_account
     *            遠端登入帳號
     *@param login_passwd
     *            遠端登入密碼
     *@return 是否成功
     *//*
    static public boolean uploadFtpFile(String local_dir, String filename, String host, int port, String login_account, String login_passwd) throws Exception {

        boolean returnValue = false;
        File outputfile = new File(local_dir, filename);
        boolean disconnectflag = true;
        FTPClient client = new FTPClient();

        try {
            client.connect(host, port);
            try {
                client.login(login_account, login_passwd);
                try {
                    client.setType(2);
                    client.upload(outputfile);
                    client.disconnect(disconnectflag);
                    returnValue = true;
                    setLog4J("debug", "com.cht.sys.CommonUtil", "CommonUtil.java uploadFtpFileFTP Success");
                } catch (Exception e13) {
                    setLog4J("error", "com.cht.sys.CommonUtil", "CommonUtil.java uploadFtpFileFTP : " + e13);
                }

            } catch (Exception e12) {
                setLog4J("error", "com.cht.sys.CommonUtil", "CommonUtil.java uploadFtpFileFTP Login [" + login_account + "] Fail : " + e12);
            }
        } catch (Exception e11) {
            setLog4J("error", "com.cht.sys.CommonUtil", "CommonUtil.java uploadFtpFileFTP Connect [" + host + ":" + port + "] Fail : " + e11);
        }
        return returnValue;
    }
*/
    /**
     *@return 現在年份(西元年)
     */
    public static String getYear() {
        Calendar rightNow = Calendar.getInstance();
        String year = "" + rightNow.get(Calendar.YEAR);
        return year;
    }

    /**
     *@return 現在月份(會自動補零)
     */
    public static String getMonth() {
        Calendar rightNow = Calendar.getInstance();
        String month = "";
        int month_t = rightNow.get(Calendar.MONTH) + 1;
        if (month_t < 10) {
            month = "0" + month_t;
        } else {
            month = "" + month_t;
        }
        return month;
    }

    /**
     *@return 現在日期
     */
    public static String getDate() {
        Calendar rightNow = Calendar.getInstance();
        String date = "" + rightNow.get(Calendar.DATE);
        return date;
    }

    /**
     *@return 當時時間
     */
    public static Calendar getCurrent() {
        Calendar rightNow = Calendar.getInstance();
        return rightNow;
    }

    /**
     *@return 當天日期
     */
    public static java.util.Date getToday() {
        java.util.Date today = getCurrent().getTime();
        return today;
    }

    /**
     *@return 當天日期(SQL Date)
     */
    public static java.sql.Date getTodaySQL() {
        java.sql.Date todaySQL = new java.sql.Date(getToday().getTime());
        return todaySQL;
    }

    public static java.util.Date getDate(String yyyy, String mm, String dd) {

        int yyyy_int = Integer.parseInt(yyyy);
        int mm_int = Integer.parseInt(mm);
        int dd_int = Integer.parseInt(dd);

        Calendar cal = Calendar.getInstance();
        cal.set(yyyy_int, mm_int, dd_int);

        java.util.Date date = cal.getTime();
        return date;
    }

    public static java.util.Date getDate(String yyyy, int mm, String dd) {

        int yyyy_int = Integer.parseInt(yyyy);
        int dd_int = Integer.parseInt(dd);

        Calendar cal = Calendar.getInstance();
        cal.set(yyyy_int, mm, dd_int);

        java.util.Date date = cal.getTime();
        return date;
    }

    public static java.util.Date getDate(int yyyy, int mm, int dd) {

        Calendar cal = Calendar.getInstance();
        cal.set(yyyy, mm, dd);

        java.util.Date date = cal.getTime();
        return date;
    }

    public static java.sql.Date getDateSQL(String yyyy, String mm, String dd) {
        java.sql.Date todaySQL = new java.sql.Date(getDate(yyyy, mm, dd).getTime());
        return todaySQL;
    }

    public static java.sql.Date getDateSQL(String yyyy, int mm, String dd) {
        java.sql.Date todaySQL = new java.sql.Date(getDate(yyyy, mm, dd).getTime());
        return todaySQL;
    }

    public static java.sql.Date getDateSQL(int yyyy, int mm, int dd) {
        java.sql.Date todaySQL = new java.sql.Date(getDate(yyyy, mm, dd).getTime());
        return todaySQL;
    }




    public static void main (String[] args) throws UnsupportedEncodingException {

        System.out.println("Start");
        String ret = CommonUtil.qryEmpAgentInfo("842a997");
        String ret2 = CommonUtil.qryEmpAgentInfo("752668");
        String ret3 = CommonUtil.qryEmpAgentInfo("009559");

//        ArrayList ret = CommonUtil.getDutyList("030124","22111");
//
//
        System.out.println(ret);
        //System.out.println(new String(ret.getBytes("ISO-8859-1"), "UTF-8"));
        System.out.println(ret2);
        System.out.println(ret3);

// test setSendMail
//        ArrayList to = new ArrayList();
//
//        String[] toList = {"王一", "aa@cht.com.tw"};
//        to.add(toList);
//        String[] toList2 = {"王二", "bb@cht.com.tw"};
//        to.add(toList2);
//        String[] toList3 = {"王三", "cc@cht.com.tw"};
//        to.add(toList3);
//
//        Map MailMap = new HashMap();
//
//        MailMap.put("subject","測試信主旨ABC");
//        MailMap.put("text","這是一個內文DEF");
//        MailMap.put("to",to);
//
//        int ret = CommonUtil.setSendMail(MailMap);
//
//        System.out.println(ret);


// test setUserAuth---
//        Set dutylist = new HashSet();
//        dutylist.add("O1");
//        dutylist.add("O3");
//        dutylist.add("X1");
//        dutylist.add("W6");
//        dutylist.add("Z5");
//
//        boolean ret = CommonUtil.setUserAuth("test","123222","testname","X1",dutylist);
//        System.out.println(ret);

// test CommonUtil.getUserByDuty
//        Iterator it = CommonUtil.getUserByDuty("O1").iterator();
//
//        while (it.hasNext()) {
//            System.out.println(it.next());
//        }

// test getUserNameSet----
//        Set UserNameSet = new HashSet();
//        UserNameSet.add("030124");
//        UserNameSet.add("830029");
//
//
//        Iterator it = CommonUtil.getUserNameSet(UserNameSet).iterator();
//
//        while (it.hasNext()) {
//
//            String[] str = (String[]) it.next();
//
//            System.out.println("employeeno : "+str[0]);
//            System.out.println("employeename : "+str[1]);
//            System.out.println("office : "+str[2]);
//        }



    }


}
